package com.gopay.common.cps.dao.fund.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.fund.FundDifferFileNotifyDAO;
import com.gopay.common.cps.dao.fund.FundGopayAccChangeNotifyDAO;
import com.gopay.common.domain.fund.FundGoapayAccChangeNotify;
import com.gopay.common.domain.fund.FundGopayReconFinishNotifyEntity;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by baiyunpeng on 16/7/21.
 */
@Repository("fundgopayAccChangeNotifyDao")
public class FundGopayAccChangeNotifyDAOImpl extends BaseDAOImpl<FundGoapayAccChangeNotify,Serializable> implements FundGopayAccChangeNotifyDAO {

    @Override
    public List<FundGoapayAccChangeNotify> getFundGoapayAccChangeNotifyByFileName(String fileName,String msgType,boolean desc,String memo){
        StringBuffer sb = new StringBuffer();
        sb.append("from FundGoapayAccChangeNotify  where fileBatchNo like :fileName and msgType=:msgType and isSucc='Y' and accountStatus='Y' ");
        if(memo!=null){
            sb.append("  and memo=:memo");
        }
        if(desc){
            sb.append(" order by createdTs desc ");
        }
        Map<String,Object> map = new HashMap<>();
        map.put("fileName",fileName);
        map.put("msgType",msgType);
        if(memo!=null){
            map.put("memo",memo);
        }
        List<FundGoapayAccChangeNotify> byHql = findByHql(sb.toString(), map);
        if(byHql!=null && byHql.size()>0) {
            return byHql;
        }
        return null;
    }

}
